<!-- 首页 -->
<template>
	<view class="container">
		<view class="c-info">
			<TeacherModule :info="teacherInfo"></TeacherModule>
		</view>
		<view class="c-util" @click="onUnbind">
			<text>解除老师关系</text>
		</view>
		<view class="c-module">
			<u-modal :show="unbindModal" title="操作确认" content='此操作一旦完成无法撤销,请确认是否解除该老师的关系' showCancelButton
				@confirm="unbindModalConfirm" @cancel="unbindModal = false"></u-modal>
		</view>
	</view>
</template>

<script>
	import TeacherModule from "@/pages/pages_mine/components/TeacherModule.vue"
	export default {
		name: "",
		components: {
			TeacherModule
		},
		data() {
			return {
				// 解绑确认模态框
				unbindModal: false,
				// 老师信息
				teacherInfo: {}
			}
		},
		onLoad(query) {
			this.getOrgTeacherInfo(query.id)
		},
		methods: {
			// 确认解绑
			unbindModalConfirm() {
				this.unbindModal = false
				this.$http.unbindTeacher({teacher_mobile:this.teacherInfo.mobile}).then(res=>{
					uni.$u.toast("已解绑")
					uni.navigateBack({
						delta:1
					})
				}).catch(err=>{
					uni.$u.toast(err.msg)
				})
			},
			// 解绑操作
			onUnbind() {
				this.unbindModal = true
			},
			// 获取老师信息
			getOrgTeacherInfo(id) {
				this.$http.getOrgTeacherInfo({
					teacher_id: id
				}).then(res => {
					this.teacherInfo = res
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		.c-util {
			font-size: 30rpx;
			color: red;
			padding: 40rpx 0;
			text-align: center;
		}
	}
</style>
